﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ConsoleTesrt.InversionOfControl
{
    internal static  class FactoryTool
    {
        public static IFactory IFactoty_ { get; set; }
        static FactoryTool()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("../app.config");
            XmlNode xmlNode = xmlDoc.ChildNodes[1].ChildNodes[0].ChildNodes[0];
  
            if ("Windows" == xmlNode.Value)
            {
                IFactoty_ = new WindowsFactory();
            }
            else if ("Mac" == xmlNode.Value)
            {
                IFactoty_ = new MacFactory();
            }
            else
            {
                throw new Exception("Factory Init Error");
            }
        }
    }
}
